#include "sys.h"
#include "log.h"
#include "hashtable.h"

int hashtable_add(struct hashtable* htable, uint32_t key, void* entry)
{
    int idx = key % htable->arrSize;
    if(htable->hlist[idx].entry == NULL){}
}

void hashtable_free(struct hashtable* htable)
{
    if (!htable)
        return;
    if (htable->hlist)
        free(htable->hlist);
    if (htable->hcount)
        free(htable->hcount);
    free(htable);
}
struct hashtable* hashtable_new(int arrSize)
{
    struct hashtable* htable = calloc(1, sizeof(struct hashtable));
    if (!htable)
        return NULL;

    htable->arrSize = arrSize;
    htable->hlist = calloc(arrSize, sizeof(struct hashtable));
    if (!htable->hlist) {
        free(htable);
        return NULL;
    }
    htable->hcount = calloc(arrSize, sizeof(int));
    if (!htable->hcount) {
        free(htable);
        return NULL;
    }
    return htable;
}
